package slideWindow;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class findAngrams {
    public static List<Integer> findAngramsTest(String s, String p){
        List<Integer>resList=new ArrayList<>();
        if (s==null||s.length()==0||s.length()<p.length()){
            return resList;
        }
        char[] pChar=p.toCharArray();
        Arrays.sort(pChar);
        int pLen=p.length();
        for (int i=0;i<s.length()-pLen+1;i++){
            String curr=s.substring(i,i+pLen);
            char[] currChar=curr.toCharArray();
            Arrays.sort(currChar);
            if (Arrays.equals(pChar,currChar)){
                resList.add(i);
            }
        }
        return resList;
    }

    public static void main(String[] args) {
        String s="cbaebabacd";
        String p="abc";
        System.out.println(findAngramsTest(s, p));
    }
}
